<?php
/**
* 账户管理
*/
class AccountControl extends CommonControl
{
	private $db = null;
	public function __auto()
	{
		$this->db = K('baseinfo');
	}

	/**
	 * 显示基础信息
	 * @return [type]
	 */
	public function baseinfo()
	{
		// p($this->db->have_info());exit;
		if(IS_POST){
			if (!$this->db->create()) $this->error($this->db->error);
			$this->db->add_data();
			$this->success('添加成功');
		}
		if($this->db->have_info()) go(U('edit_baseinfo'));
		$this->display();
	}

	/**
	 * 编辑个人信息
	 * @return [type] [description]
	 */
	public function edit_baseinfo()
	{
		if(IS_POST){
			if (!$this->db->create()) $this->error($this->db->error);
			$this->db->update_info();
		}
		$res = $this->db->get_info();
		$this->assign('res',$res);
		// p($res);
		$this->display();
	}


	public function face()
	{
		if (!$this->db->have_info()) $this->error('请先填写个人资料',U('baseinfo'));
		if (IS_POST) {
			$this->db->update_face();
			$this->success('上传成功');
		}
		$face = $this->db->get_info('face');
		// p($face);
		$this->assign('face',$face);
		$this->display();
	}

	public function password()
	{
		if(IS_POST){
			$model = K('User');
			if (!$model -> update_password()) $this->error($model->error);
			$this->success('密码修改成功');
		}
		$this->display();
	}

}




?>
